package serialport;

import android.content.Context;
import android.os.Message;
import android.util.Log;

import com.example.administrator.baseproject.BaseClass;

import java.io.OutputStream;

import beans.ScmSerialPortBean;


/**
 * Created by admin on 2017/11/21.
 */
public class DealSerialPortData extends BaseClass {
    public static final String TAG = "DealSerialPortData";

    ReceiveScmInfo receiveScmInfo;
    SendMessToScm sendMessToScm;

    public DealSerialPortData(OutputStream mOutputStream, Context mContext) {
        ScmSerialPortBean bean = new ScmSerialPortBean();
        bean.setmContext(mContext);
        bean.setmOutputStream(mOutputStream);
        bean.setSerialPortData(this);
        receiveScmInfo = new ReceiveScmInfo(bean);
        sendMessToScm = new SendMessToScm(bean);
    }

    public void receiveData(byte[] receiveData) {
        //发送应答帧
        receiveScmInfo.readAccordCommandType(receiveData);
    }

    @Override
    public void onHandleFrameMessage(Message msg) {
        sendMessToScm.onHandleMessage(msg);
    }
}
